<?php
namespace core;
class xue{
    public static $classMap = array();
    public $assign;
    static function run(){
        $route =  new \core\lib\route();
        $ctrlClass = $route->ctrl;//控制器
        $action = $route->action;//方法
        $ctrlfile = APP.'/ctrl/'.$ctrlClass.'Ctrl.php';
        $cltrlClass='\\'.MODULE.'\ctrl\\'.$ctrlClass.'Ctrl';
        if(is_file($ctrlfile)){
            include $ctrlfile;
            $ctrl = new $cltrlClass();
            $ctrl->$action();
        } else {
            throw new \Exception('找不到控制器'.$ctrlClass);
        }
    }
    static function load($class){
        $class = str_replace('\\', '/', $class);
        
        if(isset($classMap[$class])){
            return true;
        }else{
            $file = XUE.'/'.$class.'.php';
            if(is_file($file)){
                include $file;
                self::$classMap[$class] = $class;
            }else{
                return false;
            }
        }
    }
    
    public function assign($name,$val){
        $this->assign[$name] = $val;
    }
    public function dispaly($file){
        $file=APP.'/views/'.$file;
        if(is_file($file)){
            extract($this->assign);
            include $file;
        }
    }
}